package com.haonan.springboot_exercise.controller;


import com.alibaba.fastjson.JSONObject;
import com.haonan.springboot_exercise.bean.Email;
import com.haonan.springboot_exercise.dao.PopServerDao;
import com.haonan.springboot_exercise.dao.SmtpServerDao;
import com.haonan.springboot_exercise.dao.UserDao;
import com.haonan.springboot_exercise.netty.client.PopClient;
import com.haonan.springboot_exercise.netty.server.PopServer;
import com.haonan.springboot_exercise.service.SmtpServerService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetSocketAddress;

@RestController
public class TestController {
    @Autowired
    SmtpServerDao smtpServerDao;
    @Autowired
    UserDao userDao;
    @Autowired
    SmtpServerService smtpServerService;
    @Autowired
    PopServerDao popServerDao;


    @RequestMapping("/test")
    public String test(){
        synchronized (TestController.class){
            new Thread(()->{
                PopServer popServer = new PopServer();
                popServer.start(new InetSocketAddress("127.0.0.1", 110));
            }).start();
        }
        synchronized (TestController.class){
            return "ok";
        }
    }

    @RequestMapping("/test3")
    public void test3(){
        popServerDao.deleteEmailById(13);
    }
}
